//
//  Drawer.h
//  Drawer
//
//  Created by Ji Hu on 12-9-3.
//  Copyright (c) 2012年 爱辅导. All rights reserved.
//

#import <CoreGraphics/CoreGraphics.h>

#ifndef Drawer_Drawer_h
#define Drawer_Drawer_h

void outRect(CGRect *rect,float offset);
float caculate2PowAnd2Sqrt(float x,float y);
float filter(float v,float min,float max);
float caculateDistance(CGPoint *p1,CGPoint *p2);

CGPoint cPerpendicularVec(CGPoint *p);
CGPoint cAdd(CGPoint *p,CGPoint *ve,CGFloat value);
CGPoint cMin(CGPoint *p,CGPoint *ve,CGFloat value);

CGPoint direction(CGPoint from,CGPoint to);

// Helper macro that creates a CGPoint
#define ccp(__X__,__Y__) CGPointMake(__X__,__Y__)

static inline CGPoint
ccpAdd(const CGPoint v1, const CGPoint v2)
{
	return ccp(v1.x + v2.x, v1.y + v2.y);
}

static inline CGPoint
ccpMult(const CGPoint v, const CGFloat s)
{
	return ccp(v.x*s, v.y*s);
}

static inline CGPoint 
ccpMiddle(const CGPoint v, const CGPoint s)
{
	return ccp((v.x+s.x)/2.0f, (v.y+s.y)/2.0f);
}
#endif
